<template>
  <el-table
    :data="approvalHistoryList"
    style="width: 100%"
  >
    <el-table-column
      label="操作类型"
      prop="taskNodeName"
    >
    </el-table-column>
    <el-table-column
      label="操作人"
      prop="createName"
    >
    </el-table-column>
    <el-table-column
      label="执行结果"
      prop="formHistoryDataDTO"
    >
      <template slot-scope="scope">
        <el-tag
          v-if="scope.row.formHistoryDataDTO[0].value === '同意'"
          disable-transitions
          type="success"
        >同意
        </el-tag>
        <el-tag
          v-if="scope.row.formHistoryDataDTO[0].value === '不同意'"
          disable-transitions
          type="danger"
        >驳回
        </el-tag>
        <el-tag
          v-if="scope.row.formHistoryDataDTO[0].value === '已调整'"
          disable-transitions
          type="primary"
        >已调整
        </el-tag>
        <el-tag
          v-if="scope.row.formHistoryDataDTO[0].value === '已作废'"
          disable-transitions
          type="info"
        >已作废
        </el-tag>
        <el-tag
          v-if="scope.row.formHistoryDataDTO[0].value === '待定'"
          disable-transitions
          type="warning"
        >待定
        </el-tag>
        <el-tag
          v-if="scope.row.formHistoryDataDTO[0].value === '弃权'"
          disable-transitions
          type="info"
        >弃权
        </el-tag>
      </template>
    </el-table-column>
    <el-table-column
      label="操作时间"
      prop="createdDate"
    >
    </el-table-column>
    <el-table-column
      label="审批意见"
      prop="formHistoryDataDTO"
    >
      <template slot-scope="scope">
        <span>{{ scope.row.formHistoryDataDTO[1].value }}</span>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import {historyFromData} from '@/api/activiti/historyFormdata'

export default {
  name: 'ApprovalHistoryList',
  props: {
    businessKey: {
      required: true,
      type: String,
      default: ''
    }
  },
  watch: {
    businessKey(newValue, oldValue) {
      this.getHistoryFromDataList(newValue)
    }
  },
  data() {
    return {
      approvalHistoryList: []
    }
  },
  created() {
    this.getHistoryFromDataList(this.businessKey)
  },
  methods: {
    //填充列表数据
    getHistoryFromDataList(businessKey) {
      if (businessKey) {
        historyFromData(businessKey).then(response => {
          this.approvalHistoryList = response.data
        })
      }
    }
  }
}
</script>

<style scoped>

</style>
